/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package forethought.Util;
import forethought.DataObjects.Project;
import java.io.PrintWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.Date;

/**
 *
 * @author bernard_williams
 */
public class FileAccessObject {

       private Message msg = new Message();
       private Date date = new Date();

/**
 * This method creates a properly formed HTML file using the content supplied in
 * the htmlText param
 * @param htmlText HTML based content for creating reports and print outs
 * @return boolean indicates whether file write was successful or not.
 */
    public boolean writeHTML(String htmlText) {
        return true;
    }

    /**
     * This method saves the complete project object to disk.
     * @param project
     * @return
     */
    public boolean saveProject(Project project) {
        return true;
    }

    /**
     *
     * @param text
     * @param fileName
     * @return
     * @throws Exception
     */
    public boolean writeTextFile(String text, String fileName) throws Exception {

        File f = new java.io.File(fileName);
        FileWriter fw = new FileWriter(f, true);

        //Check to see if the file exists
        //if (f.exists()){
        //    msg.showErrMsg("File exists");
        //}

        //Create the file
        PrintWriter output = new PrintWriter(fw);

        //Write the data to the file
        output.println(text);


        //Close the file
        output.close();

        return true;
    }

}
